package com.spirngcloud.alibabasentinelratelimiting.controller.mq.letter;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.nio.channels.Channel;
import java.util.Date;
import java.util.Objects;

/**
 * @version V1.0
 * @Author 宋聚智
 * @Date 2019/10/24 15:20
 * @description
 * @Modify By：
 * @ModifyTime： 2019/10/24
 * @Modify marker：
 **/
@Component
@Slf4j
public class DelayReceiver {
    @RabbitListener(queues={DelayRabbitConfig.order_queue_name})
    public void orderDelayQueue(Order order){
        System.out.println("############################");
        log.info("[OrderDelayQueue 监听的消息] 消息时间={}，订单内容={}",new Date(),order.toString());
        if(Objects.equals(order.getOrderStatus(),0)){
            order.setOrderStatus(2);
            log.info("该订单未支付，取消订单。orderId={}",order.getOrderId());
        }else if(Objects.equals(order.getOrderStatus(),1)){
            log.info("该订单已完成支付，OrderId={}",order.getOrderId());
        }else if(Objects.equals(order.getOrderStatus(),2)){
            log.info("该订单已经秋霞，OrderId={}",order.getOrderId());
        }
        System.out.println("############################");
    }
}
